@(active: String,
  repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
  id: Option[String] = None,
  info: Option[Any] = None,
  error: Option[Any] = None)(body: Html)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers

@menuitem(path: String, name: String, label: String, icon: String, count: Int = 0) = {
  <li @if(active == name){class="active"}>
    @if(path.startsWith("http")){
      <a href="@path" target="_blank">
        <i class="menu-icon octicon octicon-@icon"></i> @label @if(count > 0) { <span class="label label-primary pull-right-container">@count</span> }
      </a>
    } else {
      <a href="@helpers.url(repository)@path">
        <i class="menu-icon octicon octicon-@icon"></i> @label @if(count > 0) { <span class="label label-primary pull-right-container">@count</span> }
      </a>
    }
  </li>
}

  <div class="main-sidebar">
    <div class="sidebar">
      <ul class="sidebar-menu">
        @menuitem("", "files", "Files", "code")
        @if(repository.commitCount != 0) {
          @menuitem("/branches", "branches", "Branches", "git-branch", repository.branchList.length)
          @menuitem("/tags", "tags", "Tags", "tag", repository.tags.length)
        }
        @if(repository.repository.options.enableIssues) {
          @menuitem("/issues", "issues", "Issues", "issue-opened", repository.issueCount)
          @menuitem("/pulls", "pulls", "Pull Requests", "git-pull-request", repository.pullCount)
          @menuitem("/issues/labels", "labels", "Labels", "tag")
          @menuitem("/issues/milestones", "milestones", "Milestones", "milestone")
        } else {
          @repository.repository.options.externalIssuesUrl.map { externalIssuesUrl =>
            @menuitem(externalIssuesUrl, "issues", "Issues", "issue-opened")
          }
        }
        @if(repository.repository.options.enableWiki) {
          @menuitem("/wiki", "wiki", "Wiki", "book")
        } else {
          @repository.repository.options.externalWikiUrl.map { externalWikiUrl =>
            @menuitem(externalWikiUrl, "wiki", "Wiki", "book")
          }
        }
        @if(repository.repository.options.allowFork) {
          @menuitem("/network/members", "fork", "Forks", "repo-forked", repository.forkedCount)
        }
        @if(context.loginAccount.isDefined && (context.loginAccount.get.isAdmin || repository.managers.contains(context.loginAccount.get.userName))){
          @menuitem("/settings", "settings", "Settings", "tools")
        }
        @gitbucket.core.plugin.PluginRegistry().getRepositoryMenus.map { menu =>
          @menu(repository, context).map { link =>
            @menuitem(link.path, link.id, link.label, link.icon.getOrElse("ruby"))
          }
        }
      </ul>
    </div>
  </div>
  <div class="content-wrapper">
    <div class="content body clearfix">
      <div class="headbar">
        <div class="container">
          @gitbucket.core.helper.html.information(info)
          @gitbucket.core.helper.html.error(error)
          <div class="head">
            @gitbucket.core.helper.html.repositoryicon(repository, true)
            <a href="@helpers.url(repository.owner)">@repository.owner</a> / <a href="@helpers.url(repository)" class="strong">@repository.name</a>

            @defining(repository.repository){ x =>
              @if(repository.repository.originRepositoryName.isDefined){
                <div class="forked">
                  forked from <a href="@context.path/@x.parentUserName/@x.parentRepositoryName">@x.parentUserName/@x.parentRepositoryName</a>
                </div>
              }
              @x.description.map { description =>
                <div class="normal muted" style="margin-left: 36px; font-size: 80%;">@Html(helpers.detectAndRenderLinks(description, repository))</div>
              }
            }
          </div>
        </div>
      </div>
      @body
    </div>
  </div>
</div>

